/*
	ctype.c

	part of libc-sw

	(c) Stuart Wallace <stuartw@atom.net>, 2011-07-01.
*/

#include "ctype.h"

/*
	This is a 384-byte lookup table used by the "int is<x>(int c)" functions, e.g. isupper().  Each entry consists of
	zero or more flags bitwise-ORed together.  All the is<x>() functions are then #define'd as calls to _ctypeisname(),
	which performs the appropriate lookup.
*/
static const unsigned short int _g_typetable[] =
{
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0320, 0x0220, 0x0220, 0x0220, 0x0220, 0x0200, 0x0200,
	0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200,
	0x0160, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0,
	0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x08d8, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0,
	0x04c0, 0x08d5, 0x08d5, 0x08d5, 0x08d5, 0x08d5, 0x08d5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5,
	0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x08c5, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x04c0,
	0x04c0, 0x08d6, 0x08d6, 0x08d6, 0x08d6, 0x08d6, 0x08d6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6,
	0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x08c6, 0x04c0, 0x04c0, 0x04c0, 0x04c0, 0x0200,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};

static const unsigned short int * const _g_typetable_base = _g_typetable + 128;


inline int _ctypeisname(int c, const unsigned short int type)
{
	return _g_typetable_base[c & 0xff] & type;
}

